package io;

import java.io.*;
import java.util.Scanner;

public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fis=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fis);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw,true);
        Scanner sc=new Scanner(System.in);
        System.out.println("输入内容，exit退出");
        while (true){
            String line=sc.nextLine();
            if ("exit".equals(line)){
                break;
            }
            /*
            当开启自动行刷新后，每当调用println（）方法写出一行后都会自动flush（）
             */
            pw.println(line);
        }
        pw.close();
    }
}
